package com.atguigu.gmall.all.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 李旭
 * @date 2021/11/17 10:03
 * @Description:
 */
@Controller
public class HelloController {

    //Thymeleaf入门
    @GetMapping("/hello")
    public String hello(Model model){
        model.addAttribute("world","世界你好啊");//Request对象  域中

        List<Map> listMap = new ArrayList();
        Map map1 = new HashMap();//无敌版的POJO 对象    SkuInfo
        map1.put("id",1);
        map1.put("name","刘德华");
        Map map2 = new HashMap();
        map2.put("id",2);
        map2.put("name","周泣发");
        Map map3 = new HashMap();
        map3.put("id",3);
        map3.put("name","小小熊");
        listMap.add(map1);
        listMap.add(map2);
        listMap.add(map3);
        model.addAttribute("listMap",listMap);
        model.addAttribute("num",9);


        model.addAttribute("gname","<span style=\"color:green\">宝强</span>");

        return "hello";
        //SpringMVC  前缀 后缀
    }
}
